package models

import (
	"gitee.com/sansaniot/ssiot-core/httpmvc/model"
	"gorm.io/gorm/schema"
	"time"
)

type SysDictData struct {
	DictCode  string `json:"dictCode" gorm:"primaryKey;column:dict_code;comment:主键编码"`
	DictSort  int    `json:"dictSort" gorm:"size:20;comment:DictSort"`
	DictLabel string `json:"dictLabel" gorm:"size:128;comment:DictLabel"`
	DictValue string `json:"dictValue" gorm:"size:255;comment:DictValue"`
	DictType  string `json:"dictType" gorm:"size:64;comment:DictType"`
	CssClass  string `json:"cssClass" gorm:"size:128;comment:CssClass"`
	ListClass string `json:"listClass" gorm:"size:128;comment:ListClass"`
	IsDefault string `json:"isDefault" gorm:"size:8;comment:IsDefault"`
	Status    int    `json:"status" gorm:"size:4;comment:Status"`
	Default   string `json:"default" gorm:"size:8;comment:Default"`
	Remark    string `json:"remark" gorm:"size:255;comment:Remark"`
	SystemId  string `json:"systemId" gorm:"size:255;comment:SystemId"`
	model.Model
	ControlBy
	ModelTime
}

func (SysDictData) TableName() string {
	return "sys_dict_data"
}

func (e *SysDictData) Generate() ActiveRecord {
	o := *e
	return &o
}

func (e *SysDictData) GetId() interface{} {
	return e.DictCode
}

type ControlBy struct {
	CreateBy string `json:"createBy" gorm:"index;comment:创建者"`
	UpdateBy string `json:"updateBy" gorm:"index;comment:更新者"`
}

// SetCreateBy 设置创建人id
func (e *ControlBy) SetCreateBy(createBy string) {
	e.CreateBy = createBy
}

// SetUpdateBy 设置修改人id
func (e *ControlBy) SetUpdateBy(updateBy string) {
	e.UpdateBy = updateBy
}

type Model struct {
	Id int `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
}

type ModelTime struct {
	CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
	UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"`
}

type ActiveRecord interface {
	schema.Tabler
	SetCreateBy(createBy string)
	SetUpdateBy(updateBy string)
	Generate() ActiveRecord
	GetId() interface{}
}
